/**
 * Created by Administrator on 2016/7/24.
 */
$(document).ready(function(){
    var $adPoint = $('.ad-point');
    var $buildBand = $('.build-band');
    $adPoint.mouseover(function(){
        var $this = $(this);
        var $n = $this.index();
        $buildBand.removeClass('active');
        $buildBand.eq($n).addClass('active');
    });

    var $choice = $('.choice');
    var $choiceLink = $('.choice a');
    var $choiceDisplay = $('.choice i');
    $choice.click(function(){
        var $this = $(this);
        var $n = $this.index();
        $choiceLink.removeClass('active');
        $choiceLink.eq($n).addClass('active');
        $choiceDisplay.removeClass('check');
        $choiceDisplay.eq($n).addClass('check');
    });

    var $anchorLink = $('.anchors li');
    var $anchorSign = $('.anchors a i');
    $anchorLink.click(function(){
        var $this = $(this);
        var $n = $this.index();
        $anchorLink.removeClass('current');
        $anchorLink.eq($n).addClass('current');
        $anchorSign.removeClass('show');
        $anchorSign.eq($n).addClass('show');
    });

    $(".close").click(function(){
        $(".display-layer").css("display","none");
    });

    $(".display .btn_submit").click(function(){
        $(".display-layer").css("display","block");
        var brandName=$("#brand-name").val();
        var brandIndus=$("#brand-industry").val();
        $(".specific-band").text(brandName);
        $(".indus-belong").text(brandIndus);
    });

    //var $anchorsUL = $('.anchors ul');
    $(window).scroll(function(event) {
        var windowScroll = $(this).scrollTop();
        //console.log(windowScroll)
        var $currentItem = $('');
        $('.section').each(function(index, el) {
            var min = $(el).get(0).offsetTop - windowScroll;
            if(min<180){
                $currentItem = $(el);
            }else{
                return false
            }
        });
        var num = $currentItem.attr('data-nav');
        var $currentNav = $('.anchors').find("[data-nav='"+num+"']");
        //console.log()
        highLight($currentNav,num);
    });

    //表格弹出
    $(".mselect .btn_select").click(function(){
        $(this).parents(".mselect").find(".sub-select").toggle();
    });
    $('.classify').click(function(){
        $('.display-form .sub-select').show();
    });

    $(".sub-select td").click(function(){
        var _thisTxt = $(this).text();
        $(this).parents(".mselect").find(".brand-indus").val(_thisTxt);
        $(this).parents(".mselect").find(".sub-select").hide();
    });

    $('.tele-num').blur(function(){
        if($('.tele-num').val()==""){
            $('.hint').show();
        }else{
            $('.hint').hide();
        }
    });

    $('.details-part .btn_submit').click(function(){
        if($('.tele-num').val()==""){
            $('.hint').show();
        }else{
            return;
        }
    });

    function highLight($item,n){
        $anchorLink.removeClass('current');
        $item.addClass('current');
        $anchorSign.removeClass('show');
        $anchorSign.eq(n).addClass('show');
    }
});